import Vue from 'vue'
import Router from 'vue-router'
import Scene from "../components/scene/Scene";
import Custom from "../components/custom/Custom";
import Index from "../components/Index";
import TaxInput from "@/components/tax/TaxInput";
import TaxResult from "@/components/tax/TaxResult";
import Deposit from "@/components/deposit/Deposit";
import HouseLoan from "@/components/house/HouseLoan";
import LoanResult from "@/components/house/LoanResult";
import Monthly from "../components/house/Monthly";
import Eldly from "../components/eldly/Eldly";
import BMI from "@/components/bmi/BMI";
import Age from "@/components/age/Age";

Vue.use(Router)

const paths=[
  {
    path: '',
    redirect: 'scene',
  },
  {
    path: 'scene',
    name:'场景',
    component: Scene,
    meta:{
      title:'计算器'
    }
  },
  {
    path: 'custom',
    name:'定制',
    component: Custom,
    meta:{
      title:'计算器'
    }
  },
]
let router =new Router({
  mode:'history',
  base:'/calculate/',
  routes: [
    {
      path: '/',
      redirect:'/index',
      meta:{
        title:'在线计算器'
      }
    },
    {
      path: '/index',
      name: 'index',
      component: Index,
      children:paths
    },
    {
      path: '/person_tax',
      name: 'person_tax',
      component: TaxInput,
      meta:{
        keepLive:true,
        title:'个税计算'
      }
    },
    {
      path: '/tax/result',
      name: 'tax_result',
      component: TaxResult,
      meta:{
        title:'个税计算'
      }
    },{
      path: '/deposit',
      name: 'deposit',
      component: Deposit,
      meta:{
        title:'理财计算'
      }
    },{
      path: '/house',
      name: 'HouseLoan',
      component: HouseLoan,
      meta:{
        title:'房贷计算',
        keepLive:true,
      }
    },{
      path: '/house/result',
      name: 'LoanResult',
      component: LoanResult,
      meta:{
        title:'房贷结果',
      }
    },{
      path: '/house/month',
      name: 'HouseMonthly',
      component: Monthly,
      meta:{
        title:'月供详情'
      }
    },{
      path: '/eldly',
      name: 'Eldly',
      component: Eldly,
      meta:{
        title:'养老金',
        keepLive:true
      }
    },{
      path: '/bmi',
      name: 'BMI',
      component: BMI,
      meta:{
        title:'BMI',
        keepLive:true
      }
    },{
      path: '/age',
      name: 'Age',
      component: Age,
      meta:{
        title:'岁月计算',
        keepLive:true
      }
    },
  ]
})
router.beforeEach((to,from,next) =>{
  if(to.meta&&to.meta.title){
    document.title=to.meta.title
  }
  next()
})
export default router

